package cn.com.headfree.workflow.controller;


import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.http.HttpServletRequest;

import cn.com.headfree.entity.*;
import cn.com.headfree.entity.isc.User;
import cn.com.headfree.userinfo.service.IUserInfoService;
import cn.com.headfree.util.SysDictionaryUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.gta.edu.sdk.common.dto.Page;
import com.gta.edu.sdk.util.IdGen;
import com.gta.edu.sdk.util.StringUtil;

import cn.com.headfree.base.controller.ExBaseController;
import cn.com.headfree.base.controller.ResultData;
import cn.com.headfree.depterprela.service.IDeptErpRelaService;
import cn.com.headfree.mouldshow.service.HumanDataService;
import cn.com.headfree.recordlog.service.IRecordLogService;
import cn.com.headfree.vo.workflow.DbCount;
import cn.com.headfree.vo.workflow.HadDoListVo;
import cn.com.headfree.vo.workflow.WaitDoListVo;
import cn.com.headfree.workflow.service.IWorkFlowProcessService;
import cn.com.headfree.workflow.service.IWorkFlowService;


/**
 * 工作项controller
 *
 * @author xuliang
 */
@Controller
@RequestMapping(value = "/workflow", produces = "application/json;charset=UTF-8")
public class WorkFlowController extends ExBaseController {
    private static final Logger LOG = LogManager.getLogger(WorkFlowController.class);
    private static final String SYS_CODE = "human_manage";
    @Autowired
    public IWorkFlowService workFlowService;
    @Autowired
    private IWorkFlowProcessService workFlowProcessService;
    @Autowired
    private IRecordLogService recordLogService;
    @Autowired
    private IUserInfoService userInfoService;

    @Autowired
    private IDeptErpRelaService deptErpRelaService;
    @Autowired
	private HumanDataService humanDataService;

    //基本信息
    @Value("${t_emp_base_info}")
    private String t_emp_base_info;
    //年度绩效
    @Value("${t_year_effect_info}")
    private String t_year_effect_info;
    //学历信息
    @Value("${t_educate_info}")
    private String t_educate_info;
    //教育培训及授课经历
    @Value("${t_conti_study_info}")
    private String t_conti_study_info;
    //专业技术资格
    @Value("${t_pro_tec_info}")
    private String t_pro_tec_info;
    //技能等级信息
    @Value("${t_skill_level_info}")
    private String t_skill_level_info;
    //专家人才称号
    @Value("${t_expert_title_info}")
    private String t_expert_title_info;
    //学术成果
    @Value("${t_acade_achive_info}")
    private String t_acade_achive_info;
    //制度标准
    @Value("${t_stand_info}")
    private String t_stand_info;
    //专利信息
    @Value("${t_patent_info}")
    private String t_patent_info;
    //技艺革新信息
    @Value("${t_tec_innov_info}")
    private String t_tec_innov_info;
    //竞赛考试信息
    @Value("${t_contest_info}")
    private String t_contest_info;
    //科技管理及创新成果
    @Value("${t_tec_man_innov}")
    private String t_tec_man_innov;
    //个人荣誉
    @Value("${t_honor_info}")
    private String t_honor_info;
    //项目课题成果
    @Value("${t_proj_achieve_info}")
    private String t_proj_achieve_info;
    //导师带徒
    @Value("${t_sdt_tutor_prent_info}")
    private String t_sdt_tutor_prent_info;
    //工作经历
    @Value("${t_work_exp_info}")
    private String t_work_exp_info;
    //挂职轮岗
    @Value("${t_rotation_info}")
    private String t_rotation_info;

    @RequestMapping("/getDbOrYbCountByBusinessType")
    @ResponseBody
    public ResultData getDbOrYbCountByBusinessType( HttpServletRequest request,String status) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            List<DbCount> list=workFlowService.getDbOrYbCountByBusinessType(user.getHomePostalCode(),status);
            result.setData(list);
            LOG.info("查询已办列表成功！");
        } catch (Exception e) {
            result.setErrorMsg("查询已办列表异常");
            result.setSuccess(false);
            LOG.error("查询已办列表异常", e);
        }
        return result;
    }


    /**
     * 获取代办列表
     *
     * @param waitDo
     * @param page
     * @return
     */
    @RequestMapping("/getWaitDoList")
    @ResponseBody
    public ResultData getWaitDoList(WaitDoListVo waitDo, Page<WaitDoListVo> page, HttpServletRequest request) {
        ResultData result = new ResultData();
        try {

        	 //获取登陆用户信息
            User user = getLoginUserInfo(request);
            if(user!=null) {
            	if(StringUtil.isNullOrEmpty(user.getFax())) {
            		LOG.info("当前登录用户无人资编号");
            		result.setSuccess(false);
              	  	result.setErrorMsg("当前登录用户无人资编号!");
              	  	return result;
            	}
          }else {
        	  result.setSuccess(false);
        	  result.setErrorMsg("当前登录人信息获取异常!");
        	  return result;
      	}


            String businessTypeId = waitDo.getMouldId();
//            waitDo.setCurrentLoginErpNo("30132685");
            waitDo.setCurrentLoginErpNo(user.getFax());
            waitDo.setCurrentLoginRoleCode(user.getHomePostalCode());
            if (businessTypeId.equals(t_emp_base_info)) {
                workFlowService.findWaitDoBaseInfoPageByCondition(page, waitDo);//查询基本信息
            } else if (businessTypeId.equals(t_year_effect_info)) {
                workFlowService.findWaitDoYearEffectInfoPageByCondition(page, waitDo);//查询年度绩效
            } else if (businessTypeId.equals(t_educate_info)) {
                workFlowService.findWaitDoEducationInfoPageByCondition(page, waitDo);//查询学历信息
            } else if (businessTypeId.equals(t_conti_study_info)) {
                workFlowService.findWaitDoContiStudyInfoPageByCondition(page, waitDo);//查询教育培训及授课经历
            } else if (businessTypeId.equals(t_pro_tec_info)) {
                workFlowService.findWaitDoProTecInfoPageByCondition(page, waitDo);//查询专业技术资格
            } else if (businessTypeId.equals(t_skill_level_info)) {
                workFlowService.findWaitDoSkillLevelInfoPageByCondition(page, waitDo);//查询技能等级信息
            } else if (businessTypeId.equals(t_expert_title_info)) {
                workFlowService.findWaitDoExpertTitleInfoPageByCondition(page, waitDo);//查询专家人才称号
            } else if (businessTypeId.equals(t_acade_achive_info)) {
                workFlowService.findWaitDoAcadeAchiveInfoPageByCondition(page, waitDo);//查询学术成果
            } else if (businessTypeId.equals(t_stand_info)) {
                workFlowService.findWaitDoStandInfoPageByCondition(page, waitDo);//查询制度标准
            } else if (businessTypeId.equals(t_patent_info)) {
                workFlowService.findWaitDoPatentInfoPageByCondition(page, waitDo);//查询专利信息
            } else if (businessTypeId.equals(t_tec_innov_info)) {
                workFlowService.findWaitDoTecInnovInfoPageByCondition(page, waitDo);//查询技艺革新信息
            } else if (businessTypeId.equals(t_contest_info)) {
                workFlowService.findWaitDoContestInfoPageByCondition(page, waitDo);//查询竞赛考试信息
            } else if (businessTypeId.equals(t_tec_man_innov)) {
                workFlowService.findWaitDoTecManInnovPageByCondition(page, waitDo);//查询科技管理及创新成果
            } else if (businessTypeId.equals(t_honor_info)) {
                workFlowService.findWaitDoHonorInfoPageByCondition(page, waitDo);//查询个人荣誉
            } else if (businessTypeId.equals(t_proj_achieve_info)) {
                workFlowService.findWaitDoProjAchieveInfoPageByCondition(page, waitDo);//查询项目课题成果
            } else if (businessTypeId.equals(t_sdt_tutor_prent_info)) {
                workFlowService.findWaitDoSdtTutorPrentInfoPageByCondition(page, waitDo);//查询导师带徒
            } else if (businessTypeId.equals(t_work_exp_info)) {
                workFlowService.findWaitDoWorkExpInfoPageByCondition(page, waitDo);//查询工作经历
            }else if(businessTypeId.equals(t_rotation_info)) {
            	workFlowService.findWaitDoRotationInfoPageByCondition(page, waitDo);//查询挂职轮岗
            }else {
            	result.setErrorMsg("查询待办列表异常");
                LOG.info("查询待办列表失败！");
                result.setSuccess(false);
                return result;
            }
            result.setData(page);
            LOG.info("查询待办列表成功！");
        } catch (Exception e) {
            result.setErrorMsg("查询待办列表异常");
            result.setSuccess(false);
            LOG.error("查询待办列表异常", e);
        }
        return result;
    }


    /**
     * 查询已办列表
     *
     * @param page
     * @return
     */
    @RequestMapping("/getHadDoList")
    @ResponseBody
    public ResultData getHadDoList(HadDoListVo hadDo, Page<HadDoListVo> page, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        //用于测试
//        hadDo.setErpNo("u02");
        hadDo.setCurrentLoginErpNo(user.getFax());
        hadDo.setCurrentLoginRoleCode(user.getHomePostalCode());
        try {
            workFlowService.getHadDoListByCondition(page, hadDo);
            result.setData(page);
            LOG.info("查询已办列表成功！");
        } catch (Exception e) {
            result.setErrorMsg("查询已办列表异常");
            result.setSuccess(false);
            LOG.error("查询已办列表异常", e);
        }
        return result;
    }


    /**
     * 根据登录人组织机构,获取对应的部门信息
     *
     * @return
     */
    @RequestMapping("/getDeptsByOrgId")
    @ResponseBody
    public ResultData getDeptsByOrgId(HttpServletRequest req) {
        ResultData result = new ResultData();
        try {
        	 //获取登陆用户信息
            User user = getLoginUserInfo(req);
            if(user!=null) {
            	if(StringUtil.isNullOrEmpty(user.getFax())) {
            		LOG.info("当前登录用户无人资编号");
            		result.setSuccess(false);
              	  	result.setErrorMsg("当前登录用户无人资编号");
              	  	return result;
            	}
          }else {
        	  result.setSuccess(false);
        	  result.setErrorMsg("当前登录人信息获取异常!");
        	  return result;
      	}
            //获取当前登录用户所在组织机构的一级部门
            List<TOrgDept> depts = workFlowService.getDeptsByOrgId(user);
            result.setData(depts);
        } catch (Exception e) {
            result.setErrorMsg("模糊查询信息异常");
            result.setSuccess(false);
            LOG.error("模糊查询信息异常", e);
        }
        return result;
    }

    /**
     * 根据信息类别id获取信息类别名称
     *
     * @param id
     * @return
     */
    @RequestMapping("/getMouldNameById")
    @ResponseBody
    public ResultData getMouldNameById(String id) {
        ResultData result = new ResultData();
        try {
            TMouldInfo info = workFlowService.getMouldNameById(id);
            result.setData(info);
            LOG.info("根据信息类别id获取信息类别名称成功！");
        } catch (Exception e) {
            result.setErrorMsg("根据信息类别id获取信息类别名称异常");
            result.setSuccess(false);
            LOG.error("根据信息类别id获取信息类别名称异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，基本信息
     *
     * @param baseInfo
     * @param dealOpinion
     * @param tabName
     * @return
     */
    @RequestMapping("/examineBaseInfoYes")
    @ResponseBody
    public ResultData examineBaseInfoYes(TEmpBaseInfo baseInfo, String dealOpinion, String tabName, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //个人基本信息暂不编辑
//	        workFlowService.updateBaseInfoYes(baseInfo);
            workFlowService.examineTableYes(baseInfo.getId(), user.getFax(), user.getName(), baseInfo.getOrignalId(), dealOpinion, tabName);
            TMouldInfo info = workFlowService.getMouldNameById(baseInfo.getBusinessTypeId());
            result.setData("基本信息审核成功！");
            LOG.info("基本信息审核成功！");
            //审核记录入库
            TRecordOptLog log = new TRecordOptLog();
            log.setRecordId(baseInfo.getPrimitiveId());
            log.setCurrentRecordId(baseInfo.getId());
            log.setOptType("6");
            log.setOptTime(new Date());
            if(!StringUtil.isNullOrEmpty(dealOpinion)) {
            	log.setOptContent(user.getName() + "审核同意了" + baseInfo.getCreaterName() + "提交的" + info.getMouldName() + "，审核意见:" + dealOpinion);
            }else {
            	log.setOptContent(user.getName() + "审核同意了" + baseInfo.getCreaterName() + "提交的" + info.getMouldName());
            }
            	//保存业务记录操作日志信息记录
            recordLogService.save(user, log);

        } catch (Exception e) {
            result.setErrorMsg("基本信息审核异常");
            result.setSuccess(false);
            LOG.error("基本信息审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，年度绩效
     *
     * @param yearEffectInfo
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineYearEffectYes")
    @ResponseBody
    public ResultData examineYearEffectYes(TYearEffectInfo yearEffectInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TYearEffectInfo oldTYearEffectInfo = userInfoService.getYearEffectById(yearEffectInfo.getId());
            //编辑年度绩效
            yearEffectInfo.setFlowStatus(1);//审核通过
            yearEffectInfo.setIsValid(0);
            workFlowService.updateYearEffect(yearEffectInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(yearEffectInfo.getId(), user.getFax(), user.getName(), yearEffectInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("年度绩效审核成功！");
            LOG.info("年度绩效审核成功！");
            //审核记录入库`
            oldTYearEffectInfo.setPerforGrade(SysDictionaryUtil.getNameByValueForDefault("PerformLevelRecentThreeYears",oldTYearEffectInfo.getPerforGrade()));//绩效等级
            yearEffectInfo.setPerforGrade(SysDictionaryUtil.getNameByValueForDefault("PerformLevelRecentThreeYears",yearEffectInfo.getPerforGrade()));//绩效等级
            addRecordLog(yearEffectInfo.getBusinessTypeId(),yearEffectInfo.getPrimitiveId(),yearEffectInfo.getId(),"6",dealOpinion,yearEffectInfo.getCreaterName(),yearEffectInfo,oldTYearEffectInfo,user);
//            	//保存业务记录操作日志信息记录
//            recordLogService.save(user, log);
        } catch (Exception e) {
            result.setErrorMsg("年度绩效审核异常");
            result.setSuccess(false);
            LOG.error("年度绩效审核异常", e);
        }
        return result;
    }

    /**
     * 审核——》同意，学历信息
     *
     * @param educateInfo
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineEducateInfoYes")
    @ResponseBody
    public ResultData examineEducateInfoYes(TEducateInfo educateInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TEducateInfo oldTEducateInfo = userInfoService.getEducateInfoById(educateInfo.getId());
            //编辑学历信息
            educateInfo.setFlowStatus(1);//审核通过
            educateInfo.setIsValid(0);
            workFlowService.updateEducateInfoYes(educateInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(educateInfo.getId(), user.getFax(), user.getName(), educateInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("学历信息审核成功！");
            LOG.info("学历信息审核成功！");
            //审核记录入库
            oldTEducateInfo.setSchoolType(SysDictionaryUtil.getNameByValueForDefault("CollegeCategory",oldTEducateInfo.getSchoolType()));//院校类别
            oldTEducateInfo.setEducName(SysDictionaryUtil.getNameByValueForDefault("PersonnelQualifications",oldTEducateInfo.getEducName()));//学历名称
            oldTEducateInfo.setDegreeName(SysDictionaryUtil.getNameByValueForDefault("AcademicDegree",oldTEducateInfo.getDegreeName()));//学位名称
            educateInfo.setSchoolType(SysDictionaryUtil.getNameByValueForDefault("CollegeCategory",educateInfo.getSchoolType()));//院校类别
            educateInfo.setEducName(SysDictionaryUtil.getNameByValueForDefault("PersonnelQualifications",educateInfo.getEducName()));//学历名称
            educateInfo.setDegreeName(SysDictionaryUtil.getNameByValueForDefault("AcademicDegree",educateInfo.getDegreeName()));//学位名称
            addRecordLog(educateInfo.getBusinessTypeId(),educateInfo.getPrimitiveId(),educateInfo.getId(),"6",dealOpinion,educateInfo.getCreaterName(),educateInfo,oldTEducateInfo,user);
//            //保存业务记录操作日志信息记录
//            recordLogService.save(user, log);
        } catch (Exception e) {
            result.setErrorMsg("学历信息审核异常");
            result.setSuccess(false);
            LOG.error("学历信息审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，教育培训及授课经历
     *
     * @param contiStudyInfo
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineContiStudyInfoYes")
    @ResponseBody
    public ResultData examineContiStudyInfoYes(TContiStudyInfo contiStudyInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TContiStudyInfo oldTContiStudyInfo = userInfoService.getContiStudyInfoById(contiStudyInfo.getId());
            //编辑教育培训及授课经历
//	        workFlowService.updateBaseInfoYes(baseInfo);
            contiStudyInfo.setFlowStatus(1);//审核通过
            contiStudyInfo.setIsValid(0);
            workFlowProcessService.updateTContiStudyInfo(contiStudyInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(contiStudyInfo.getId(), user.getFax(), user.getName(), contiStudyInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("教育培训及授课经历审核成功！");
            LOG.info("教育培训及授课经历审核成功！");
            //审核记录入库
            oldTContiStudyInfo.setType(SysDictionaryUtil.getNameByValueForDefault("PeixunshoukeType",oldTContiStudyInfo.getType()));//类别
            contiStudyInfo.setType(SysDictionaryUtil.getNameByValueForDefault("PeixunshoukeType",contiStudyInfo.getType()));//类别
            addRecordLog(contiStudyInfo.getBusinessTypeId(),contiStudyInfo.getPrimitiveId(),contiStudyInfo.getId(),"6",dealOpinion,contiStudyInfo.getCreaterName(),contiStudyInfo,oldTContiStudyInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("教育培训及授课经历审核异常");
            result.setSuccess(false);
            LOG.error("教育培训及授课经历审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，专业技术资格
     *
     * @param proTecInfo
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineProTecInfoYes")
    @ResponseBody
    public ResultData examineProTecInfoYes(TProTecInfo proTecInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
//        User user = new User();
//        user.setFax("30132685");
//        user.setUserName("臧家宁");
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TProTecInfo oldTProTecInfo = userInfoService.getProTecInfoById(proTecInfo.getId());
            //编辑专业技术资格
//	        workFlowService.updateBaseInfoYes(baseInfo);
            proTecInfo.setFlowStatus(1);//审核通过
            proTecInfo.setIsValid(0);
            workFlowProcessService.updateTProTecInfo(proTecInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(proTecInfo.getId(), user.getFax(), user.getName(), proTecInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("专业技术资格审核成功！");
            LOG.info("专业技术资格审核成功！");
            //审核记录入库
            oldTProTecInfo.setSubjSet(SysDictionaryUtil.getNameByValueForDefault("ProTechnicalQualifications",oldTProTecInfo.getSubjSet()));//专业技术资格系列
            oldTProTecInfo.setSubjLevel(SysDictionaryUtil.getNameByValueForDefault("ProfessionalQualifications",oldTProTecInfo.getSubjLevel()));//专业技术资格等级
            oldTProTecInfo.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",oldTProTecInfo.getOrgLevel()));//发证单位级别
            proTecInfo.setSubjSet(SysDictionaryUtil.getNameByValueForDefault("ProTechnicalQualifications",proTecInfo.getSubjSet()));//专业技术资格系列
            proTecInfo.setSubjLevel(SysDictionaryUtil.getNameByValueForDefault("ProfessionalQualifications",proTecInfo.getSubjLevel()));//专业技术资格等级
            proTecInfo.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",proTecInfo.getOrgLevel()));//发证单位级别
            addRecordLog(proTecInfo.getBusinessTypeId(),proTecInfo.getPrimitiveId(),proTecInfo.getId(),"6",dealOpinion,proTecInfo.getCreaterName(),proTecInfo,oldTProTecInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("专业技术资格审核异常");
            result.setSuccess(false);
            LOG.error("专业技术资格审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，技能等级信息
     *
     * @param skillLevelInfo
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineSkillLevelInfoYes")
    @ResponseBody
    public ResultData examineSkillLevelInfoYes(TSkillLevelInfo skillLevelInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
//        User user = new User();
//        user.setFax("30132685");
//        user.setUserName("臧家宁");
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TSkillLevelInfo oldTSkillLevelInfo = userInfoService.getSkillLevelInfoById(skillLevelInfo.getId());
            //编辑技能等级信息
//	        workFlowService.updateBaseInfoYes(baseInfo);
            skillLevelInfo.setFlowStatus(1);//审核通过
            skillLevelInfo.setIsValid(0);
            workFlowProcessService.updateTSkillLevelInfo(skillLevelInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(skillLevelInfo.getId(), user.getFax(), user.getName(), skillLevelInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("技能等级信息审核成功！");
            LOG.info("技能等级信息审核成功！");
            //审核记录入库
            oldTSkillLevelInfo.setTechType(SysDictionaryUtil.getNameByValueForDefault("SkillAppraisalWork",oldTSkillLevelInfo.getTechType()));//技能鉴定工种
            oldTSkillLevelInfo.setQualifiLevel(SysDictionaryUtil.getNameByValueForDefault("QualificationLevel",oldTSkillLevelInfo.getQualifiLevel()));//职业资格等级
            oldTSkillLevelInfo.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",oldTSkillLevelInfo.getOrgLevel()));//发证单位级别
            skillLevelInfo.setTechType(SysDictionaryUtil.getNameByValueForDefault("SkillAppraisalWork",skillLevelInfo.getTechType()));//技能鉴定工种
            skillLevelInfo.setQualifiLevel(SysDictionaryUtil.getNameByValueForDefault("QualificationLevel",skillLevelInfo.getQualifiLevel()));//职业资格等级
            skillLevelInfo.setOrgLevel(SysDictionaryUtil.getNameByValueForDefault("IdentificationUnitLevel",skillLevelInfo.getOrgLevel()));//发证单位级别
            addRecordLog(skillLevelInfo.getBusinessTypeId(),skillLevelInfo.getPrimitiveId(),skillLevelInfo.getId(),"6",dealOpinion,skillLevelInfo.getCreaterName(),skillLevelInfo,oldTSkillLevelInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("技能等级信息审核异常");
            result.setSuccess(false);
            LOG.error("技能等级信息审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，专家人才称号
     *
     * @param expertTitleInfo
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineExpertTitleInfoYes")
    @ResponseBody
    public ResultData examineExpertTitleInfoYes(TExpertTitleInfo expertTitleInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
//        User user = new User();
//        user.setFax("30132685");
//        user.setUserName("臧家宁");
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TExpertTitleInfo oldTExpertTitleInfo = userInfoService.getExpertTitleInfoById(expertTitleInfo.getId());
            //编辑专家人才称号
//	        workFlowService.updateBaseInfoYes(baseInfo);
            expertTitleInfo.setFlowStatus(1);//审核通过
            expertTitleInfo.setIsValid(0);
            workFlowProcessService.updateTExpertTitleInfo(expertTitleInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(expertTitleInfo.getId(), user.getFax(), user.getName(), expertTitleInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("专家人才称号审核成功！");
            LOG.info("专家人才称号审核成功！");
            //审核记录入库
            oldTExpertTitleInfo.setLevelName(SysDictionaryUtil.getNameByValueForDefault("ExpertLevel",oldTExpertTitleInfo.getLevelName()));//等级
            oldTExpertTitleInfo.setType(SysDictionaryUtil.getNameByValueForDefault("ExpertCategory",oldTExpertTitleInfo.getType()));//类别
            oldTExpertTitleInfo.setMajor(SysDictionaryUtil.getNameByValueForDefault("ProWorkTypes",oldTExpertTitleInfo.getMajor()));//专业
            oldTExpertTitleInfo.setEmpTitle(SysDictionaryUtil.getNameByValueForDefault("TalentTitle",oldTExpertTitleInfo.getEmpTitle()));//专家人才称号
            expertTitleInfo.setLevelName(SysDictionaryUtil.getNameByValueForDefault("ExpertLevel",expertTitleInfo.getLevelName()));//等级
            expertTitleInfo.setType(SysDictionaryUtil.getNameByValueForDefault("ExpertCategory",expertTitleInfo.getType()));//类别
            expertTitleInfo.setMajor(SysDictionaryUtil.getNameByValueForDefault("ProWorkTypes",expertTitleInfo.getMajor()));//专业
            expertTitleInfo.setEmpTitle(SysDictionaryUtil.getNameByValueForDefault("TalentTitle",expertTitleInfo.getEmpTitle()));//专家人才称号
            addRecordLog(expertTitleInfo.getBusinessTypeId(),expertTitleInfo.getPrimitiveId(),expertTitleInfo.getId(),"6",dealOpinion,expertTitleInfo.getCreaterName(),expertTitleInfo,oldTExpertTitleInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("专家人才称号审核异常");
            result.setSuccess(false);
            LOG.error("专家人才称号审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，学术成果
     *
     * @param acadeAchiveInfo
     * @return
     */
    @RequestMapping("/examineAcadeAchiveInfoYes")
    @ResponseBody
    public ResultData examineAcadeAchiveInfoYes(@RequestBody TAcadeAchiveInfo acadeAchiveInfo, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
//        User user = new User();
//        user.setFax("30132685");
//        user.setUserName("臧家宁");
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TAcadeAchiveInfo oldTAcadeAchiveInfo = userInfoService.getAcadeAchiveInfoByIdForRecord(acadeAchiveInfo.getId());
            //编辑学术成果
//	        workFlowService.updateBaseInfoYes(baseInfo);
            //编辑主表数据
            acadeAchiveInfo.setFlowStatus(1);//审核通过
            acadeAchiveInfo.setIsValid(0);
            workFlowProcessService.updateTAcadeAchiveInfo(acadeAchiveInfo, user);//审核时编辑数据
            //参与人员修改
            userInfoService.updatePartRankData(acadeAchiveInfo.getId(),acadeAchiveInfo.gettPartRankList(),"12");
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(acadeAchiveInfo.getId(), user.getFax(), user.getName(), acadeAchiveInfo.getOrignalId(), acadeAchiveInfo.getDealOpinion(), acadeAchiveInfo.getTabName());
            result.setData("学术成果审核成功！");
            LOG.info("学术成果审核成功！");
            //审核记录入库
            oldTAcadeAchiveInfo.setLevel(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJb",oldTAcadeAchiveInfo.getLevel()));//级别
            oldTAcadeAchiveInfo.setAcadType(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoType",oldTAcadeAchiveInfo.getAcadType()));//类别
            acadeAchiveInfo.setLevel(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJb",acadeAchiveInfo.getLevel()));//级别
            acadeAchiveInfo.setAcadType(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoType",acadeAchiveInfo.getAcadType()));//类别
            List<TPartRank> tPartRanks = acadeAchiveInfo.gettPartRankList();
            if(tPartRanks.size() > 0){
                for(TPartRank rank:tPartRanks){
                    rank.setRoleName(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJs",rank.getRole()));
                }
            }
            addRecordLog(acadeAchiveInfo.getBusinessTypeId(),acadeAchiveInfo.getPrimitiveId(),acadeAchiveInfo.getId(),"6",acadeAchiveInfo.getDealOpinion(),acadeAchiveInfo.getCreaterName(),acadeAchiveInfo,oldTAcadeAchiveInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("学术成果审核异常");
            result.setSuccess(false);
            LOG.error("学术成果审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，制度标准
     *
     * @param standInfo
     * @return
     */
    @RequestMapping("/examineStandInfoYes")
    @ResponseBody
    public ResultData examineStandInfoYes(@RequestBody TStandInfo standInfo, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TStandInfo oldTStandInfo = userInfoService.getStandInfoByIdForRecord(standInfo.getId());
            //编辑制度标准
//	        workFlowService.updateBaseInfoYes(baseInfo);
            standInfo.setFlowStatus(1);//审核通过
            standInfo.setIsValid(0);
            workFlowProcessService.updateTStandInfo(standInfo, user);//审核时编辑数据
//            //删除子表数据
//            workFlowService.deleteTPartRankByCondition(standInfo.getId());
//            //给字表新增数据
//            tPartRank.setId(IdGen.uuid());
//            tPartRank.setItemId(standInfo.getId());
//            tPartRank.setItemType("13");
//            workFlowService.addPartRank(tPartRank);

            //参与人员修改
            userInfoService.updatePartRankData(standInfo.getId(),standInfo.gettPartRankList(),"13");
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(standInfo.getId(), user.getFax(), user.getName(), standInfo.getOrignalId(), standInfo.getDealOpinion(), standInfo.getTabName());
            result.setData("制度标准审核成功！");
            LOG.info("制度标准审核成功！");
            //审核记录入库
            oldTStandInfo.setType(SysDictionaryUtil.getNameByValueForDefault("ZdbzType",oldTStandInfo.getType()));//类别
            oldTStandInfo.setLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",oldTStandInfo.getLevel()));//级别
            standInfo.setType(SysDictionaryUtil.getNameByValueForDefault("ZdbzType",standInfo.getType()));//类别
            standInfo.setLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",standInfo.getLevel()));//级别
            List<TPartRank> tPartRanks = standInfo.gettPartRankList();
            if(tPartRanks.size() > 0){
                for(TPartRank rank:tPartRanks){
                    rank.setRoleName(SysDictionaryUtil.getNameByValueForDefault("XueshuchengguoJs",rank.getRole()));
                }
            }
            addRecordLog(standInfo.getBusinessTypeId(),standInfo.getPrimitiveId(),standInfo.getId(),"6",standInfo.getDealOpinion(),standInfo.getCreaterName(),standInfo,oldTStandInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("制度标准审核异常");
            result.setSuccess(false);
            LOG.error("制度标准审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，专利信息
     *
     * @return
     */
    @RequestMapping("/examinePatentInfoYes")
    @ResponseBody
    public ResultData examinePatentInfoYes(@RequestBody TPatentInfo patentInfo, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TPatentInfo oldTPatentInfo = userInfoService.getPatentInfoByIdForRecord(patentInfo.getId());
            //编辑专利信息
//	        workFlowService.updateBaseInfoYes(baseInfo);
            patentInfo.setFlowStatus(1);//审核通过
            patentInfo.setIsValid(0);
            workFlowProcessService.updateTPatentInfo(patentInfo, user);//审核时编辑数据
            //参与人员修改
            userInfoService.updatePartRankData(patentInfo.getId(),patentInfo.gettPartRankList(),"14");
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(patentInfo.getId(), user.getFax(), user.getName(), patentInfo.getOrignalId(), patentInfo.getDealOpinion(), patentInfo.getTabName());
            result.setData("专利信息审核成功！");
            LOG.info("专利信息审核成功！");
            //审核记录入库
            oldTPatentInfo.setPatentType(SysDictionaryUtil.getNameByValueForDefault("PatentType",oldTPatentInfo.getPatentType()));//类别
            patentInfo.setPatentType(SysDictionaryUtil.getNameByValueForDefault("PatentType",patentInfo.getPatentType()));//类别
            addRecordLog(patentInfo.getBusinessTypeId(),patentInfo.getPrimitiveId(),patentInfo.getId(),"6",patentInfo.getDealOpinion(),patentInfo.getCreaterName(),patentInfo,oldTPatentInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("专利信息审核异常");
            result.setSuccess(false);
            LOG.error("专利信息审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，技艺革新信息
     *
     * @return
     */
    @RequestMapping("/examineTecInnovInfoYes")
    @ResponseBody
    public ResultData examineTecInnovInfoYes(@RequestBody TTecInnovInfo tecInnovInfo, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TTecInnovInfo oldTTecInnovInfo = userInfoService.getTecInnovInfoByIdForRecord(tecInnovInfo.getId());
            //编辑专利信息
//	        workFlowService.updateBaseInfoYes(baseInfo);
            tecInnovInfo.setFlowStatus(1);//审核通过
            tecInnovInfo.setIsValid(0);
            workFlowProcessService.updateTTecInnovInfo(tecInnovInfo, user);//审核时编辑数据
            //参与人员修改
            userInfoService.updatePartRankData(tecInnovInfo.getId(),tecInnovInfo.gettPartRankList(),"15");
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(tecInnovInfo.getId(), user.getFax(), user.getName(), tecInnovInfo.getOrignalId(), tecInnovInfo.getDealOpinion(), tecInnovInfo.getTabName());
            result.setData("技艺革新信息审核成功！");
            LOG.info("技艺革新信息审核成功！");
            //审核记录入库
            oldTTecInnovInfo.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",oldTTecInnovInfo.getAwardLevel()));//QC获奖级别
            oldTTecInnovInfo.setAwardGrade(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",oldTTecInnovInfo.getAwardGrade()));//奖项等级
            oldTTecInnovInfo.setAwardType(SysDictionaryUtil.getNameByValueForDefault("jiyigexinType",oldTTecInnovInfo.getAwardType()));//类型
            tecInnovInfo.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",tecInnovInfo.getAwardLevel()));//QC获奖级别
            tecInnovInfo.setAwardGrade(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",tecInnovInfo.getAwardGrade()));//奖项等级
            tecInnovInfo.setAwardType(SysDictionaryUtil.getNameByValueForDefault("jiyigexinType",tecInnovInfo.getAwardType()));//类型
            addRecordLog(tecInnovInfo.getBusinessTypeId(),tecInnovInfo.getPrimitiveId(),tecInnovInfo.getId(),"6",tecInnovInfo.getDealOpinion(),tecInnovInfo.getCreaterName(),tecInnovInfo,oldTTecInnovInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("技艺革新信息审核异常");
            result.setSuccess(false);
            LOG.error("技艺革新信息审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，竞赛考试信息
     *
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineContestInfoYes")
    @ResponseBody
    public ResultData examineContestInfoYes(TContestInfo contestInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TContestInfo oldTContestInfo = userInfoService.getContestInfoById(contestInfo.getId());
            //编辑竞赛考试信息
            contestInfo.setFlowStatus(1);//审核通过
            contestInfo.setIsValid(0);
            workFlowProcessService.updateTContestInfo(contestInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(contestInfo.getId(), user.getFax(), user.getName(), contestInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("竞赛考试信息审核成功！");
            LOG.info("竞赛考试信息审核成功！");
            //审核记录入库
            oldTContestInfo.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",oldTContestInfo.getAwardLevel()));//竞赛考试获奖级别
            oldTContestInfo.setCompRank(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",oldTContestInfo.getCompRank()));//竞赛考试名次
            if(oldTContestInfo.getGetTitle().equals("0")){oldTContestInfo.setGetTitle("是");}else{oldTContestInfo.setGetTitle("否");}
            contestInfo.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",contestInfo.getAwardLevel()));//竞赛考试获奖级别
            contestInfo.setCompRank(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",contestInfo.getCompRank()));//竞赛考试名次
            if(contestInfo.getGetTitle().equals("0")){contestInfo.setGetTitle("是");}else{contestInfo.setGetTitle("否");}
            addRecordLog(contestInfo.getBusinessTypeId(),contestInfo.getPrimitiveId(),contestInfo.getId(),"6",dealOpinion,contestInfo.getCreaterName(),contestInfo,oldTContestInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("竞赛考试信息审核异常");
            result.setSuccess(false);
            LOG.error("竞赛考试信息审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，科技管理及创新成果
     *
     * @return
     */
    @RequestMapping("/examineTecManInnovYes")
    @ResponseBody
    public ResultData examineTecManInnovYes(@RequestBody TTecManInnov tecManInnov, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TTecManInnov oldTTecManInnov = userInfoService.getTecManInnovByIdForRecord(tecManInnov.getId());
            //编辑科技管理及创新成果
            tecManInnov.setFlowStatus(1);//审核通过
            tecManInnov.setIsValid(0);
            workFlowProcessService.updateTTecManInnov(tecManInnov, user);//审核时编辑数据
            //参与人员修改
            userInfoService.updatePartRankData(tecManInnov.getId(),tecManInnov.gettPartRankList(),"16");
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(tecManInnov.getId(), user.getFax(), user.getName(), tecManInnov.getOrignalId(), tecManInnov.getDealOpinion(), tecManInnov.getTabName());
            result.setData("科技管理及创新成果审核成功！");
            LOG.info("科技管理及创新成果审核成功！");
            //审核记录入库
            oldTTecManInnov.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",oldTTecManInnov.getAwardLevel()));//获奖级别
            oldTTecManInnov.setAwardGrade(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",oldTTecManInnov.getAwardGrade()));//奖项等级
            oldTTecManInnov.setAchiType(SysDictionaryUtil.getNameByValueForDefault("KjglAchiveType",oldTTecManInnov.getAchiType()));//成果类别
            tecManInnov.setAwardLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",tecManInnov.getAwardLevel()));//获奖级别
            tecManInnov.setAwardGrade(SysDictionaryUtil.getNameByValueForDefault("JygexinQcDj",tecManInnov.getAwardGrade()));//奖项等级
            tecManInnov.setAchiType(SysDictionaryUtil.getNameByValueForDefault("KjglAchiveType",tecManInnov.getAchiType()));//成果类别
            addRecordLog(tecManInnov.getBusinessTypeId(),tecManInnov.getPrimitiveId(),tecManInnov.getId(),"6",tecManInnov.getDealOpinion(),tecManInnov.getCreaterName(),tecManInnov,oldTTecManInnov,user);
        } catch (Exception e) {
            result.setErrorMsg("科技管理及创新成果审核异常");
            result.setSuccess(false);
            LOG.error("科技管理及创新成果审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，个人荣誉
     *
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineHonorInfoYes")
    @ResponseBody
    public ResultData examineHonorInfoYes(THonorInfo honorInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            THonorInfo oldTHonorInfo = userInfoService.getHonorInfoById(honorInfo.getId());
            //编辑个人荣誉
//	        workFlowService.updateBaseInfoYes(baseInfo);
            honorInfo.setFlowStatus(1);//审核通过
            honorInfo.setIsValid(0);
            workFlowProcessService.updateTHonorInfo(honorInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(honorInfo.getId(), user.getFax(), user.getName(), honorInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("个人荣誉审核成功！");
            LOG.info("个人荣誉审核成功！");
            //审核记录入库
            oldTHonorInfo.setHonorLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",oldTHonorInfo.getHonorLevel()));
            oldTHonorInfo.setHonorType(SysDictionaryUtil.getNameByValueForDefault("RuYuLeiBie",oldTHonorInfo.getHonorType()));
            honorInfo.setHonorLevel(SysDictionaryUtil.getNameByValueForDefault("JygexinQcJb",honorInfo.getHonorLevel()));
            honorInfo.setHonorType(SysDictionaryUtil.getNameByValueForDefault("RuYuLeiBie",honorInfo.getHonorType()));
            addRecordLog(honorInfo.getBusinessTypeId(),honorInfo.getPrimitiveId(),honorInfo.getId(),"6",dealOpinion,honorInfo.getCreaterName(),honorInfo,oldTHonorInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("个人荣誉审核异常");
            result.setSuccess(false);
            LOG.error("个人荣誉审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，项目课题成果
     *
     * @param projAchieveInfo
     * @return
     */
    @RequestMapping("/examineProjAchieveInfoYes")
    @ResponseBody
    public ResultData examineProjAchieveInfoYes(@RequestBody TProjAchieveInfo projAchieveInfo, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TProjAchieveInfo oldTProjAchieveInfo = userInfoService.getProjAchieveInfoByIdForRecord(projAchieveInfo.getId());
            //编辑项目课题成果
            projAchieveInfo.setFlowStatus(1);//审核通过
            projAchieveInfo.setIsValid(0);
            workFlowProcessService.updateTProjAchieveInfo(projAchieveInfo, user);//审核时编辑数据
            //参与人员修改
            userInfoService.updatePartRankData(projAchieveInfo.getId(),projAchieveInfo.gettPartRankList(),"17");
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(projAchieveInfo.getId(), user.getFax(), user.getName(), projAchieveInfo.getOrignalId(), projAchieveInfo.getDealOpinion(), projAchieveInfo.getTabName());
            result.setData("项目课题成果审核成功！");
            LOG.info("项目课题成果审核成功！");
            //审核记录入库
            oldTProjAchieveInfo.setProjLevel(SysDictionaryUtil.getNameByValueForDefault("StandardLevel",oldTProjAchieveInfo.getProjLevel()));
            projAchieveInfo.setProjLevel(SysDictionaryUtil.getNameByValueForDefault("StandardLevel",projAchieveInfo.getProjLevel()));
            List<TPartRank> tPartRanks = projAchieveInfo.gettPartRankList();
            if(tPartRanks.size() > 0){
                for(TPartRank rank:tPartRanks){
                    rank.setRoleName(SysDictionaryUtil.getNameByValueForDefault("XiangMuKeTiJS",rank.getRole()));
                }
            }
            addRecordLog(projAchieveInfo.getBusinessTypeId(),projAchieveInfo.getPrimitiveId(),projAchieveInfo.getId(),"6",projAchieveInfo.getDealOpinion(),projAchieveInfo.getCreaterName(),projAchieveInfo,oldTProjAchieveInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("项目课题成果审核异常");
            result.setSuccess(false);
            LOG.error("项目课题成果审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，导师带徒
     *
     * @param sdtTutorPrentInfo
     * @return
     */
    @RequestMapping("/examineSdtTutorPrentInfoYes")
    @ResponseBody
    public ResultData examineSdtTutorPrentInfoYes(@RequestBody TSdtTutorPrentInfo sdtTutorPrentInfo, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TSdtTutorPrentInfo oldTSdtTutorPrentInfo = userInfoService.getSdtTutorPrentInfoById(sdtTutorPrentInfo.getId());
            //编辑导师带徒
            sdtTutorPrentInfo.setFlowStatus(1);//审核通过
            sdtTutorPrentInfo.setIsValid(0);
            workFlowProcessService.updateTSdtTutorPrentInfo(sdtTutorPrentInfo, user);//审核时编辑数据
            List<TSdtPrentInfo> prents = sdtTutorPrentInfo.gettSdtPrentInfo();
            //先删除徒弟所获奖项信息
			List<TSdtPrentInfo> prentInfos = userInfoService.getTSdtPrentInfoListById(sdtTutorPrentInfo.getId());
			if(prentInfos != null && prentInfos.size()>0){
				prentInfos.forEach(p ->{
					humanDataService.deleteTSdtAwardBySdtTdId(p.getId());
				});
			}
			//再删除徒弟信息
            workFlowService.deleteTSdtPrentInfoByCondition(null,sdtTutorPrentInfo.getId());
//            List<TSdtPrentInfo> prentList = sdtTutorPrentInfo.gettSdtPrentInfo();
            // 管理员修改时只是修改，先将原徒弟信息和徒弟所获奖项删除，然后再新增
    		if(prents.size() > 0){
    			prents.forEach(p ->{
    				p.setId(IdGen.uuid());
    				p.setSdtId(sdtTutorPrentInfo.getId());
    				p.setCreaterId(user.getFax());
    				p.setCreaterName(user.getName());
    				p.setDelSign(0);
    				if(StringUtil.isNullOrEmpty(p.getErpNo())){
    				    p.setErpNo(p.getUserName());
                    }
    				userInfoService.addSdtPrentInfo(p);
    				List<TSdtAward> tSdtAwards = p.gettSdtAwardList();
    				if(tSdtAwards != null && tSdtAwards.size()>0){
    					tSdtAwards.forEach(t ->{
    						t.setId(IdGen.uuid());
    						t.setSdtTdId(p.getId());
    						t.setCreaterId(user.getFax());
    						t.setCreaterName(user.getName());
    						t.setUpdaterId(user.getFax());
    						t.setUpdaterName(user.getName());
    						userInfoService.addSdtAwardInfo(t);
    					});
    				}
    			});
    		}
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(sdtTutorPrentInfo.getId(), user.getFax(), user.getName(), sdtTutorPrentInfo.getOrignalId(), sdtTutorPrentInfo.getDealOpinion(), sdtTutorPrentInfo.getTabName());
            result.setData("导师带徒审核成功！");
            LOG.info("导师带徒审核成功！");
            //审核记录入库
            addRecordLog(sdtTutorPrentInfo.getBusinessTypeId(),sdtTutorPrentInfo.getPrimitiveId(),sdtTutorPrentInfo.getId(),"6",sdtTutorPrentInfo.getDealOpinion(),sdtTutorPrentInfo.getCreaterName(),sdtTutorPrentInfo,oldTSdtTutorPrentInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("导师带徒审核异常");
            result.setSuccess(false);
            LOG.error("导师带徒审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，工作经历
     *
     * @param workExpInfo
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineWorkExpInfoYes")
    @ResponseBody
    public ResultData examineWorkExpInfoYes(TWorkExpInfo workExpInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TWorkExpInfo oldTWorkExpInfo = userInfoService.getWorkExpInfoById(workExpInfo.getId());
            //编辑工作经历
//	        workFlowService.updateBaseInfoYes(baseInfo);
            workExpInfo.setFlowStatus(1);//审核通过
            workExpInfo.setIsValid(0);
            workFlowProcessService.updateTWorkExpInfo(workExpInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(workExpInfo.getId(), user.getFax(), user.getName(), workExpInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("工作经历审核成功！");
            LOG.info("工作经历审核成功！");
            //审核记录入库
            oldTWorkExpInfo.setRank(SysDictionaryUtil.getNameByValueForDefault("DutyLevel",oldTWorkExpInfo.getRank()));//级别
            oldTWorkExpInfo.setPostType(SysDictionaryUtil.getNameByValueForDefault("PostCategory",oldTWorkExpInfo.getPostType()));//岗位类别
            workExpInfo.setRank(SysDictionaryUtil.getNameByValueForDefault("DutyLevel",workExpInfo.getRank()));//级别
            workExpInfo.setPostType(SysDictionaryUtil.getNameByValueForDefault("PostCategory",workExpInfo.getPostType()));//岗位类别
            addRecordLog(workExpInfo.getBusinessTypeId(),workExpInfo.getPrimitiveId(),workExpInfo.getId(),"6",dealOpinion,workExpInfo.getCreaterName(),workExpInfo,oldTWorkExpInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("工作经历审核异常");
            result.setSuccess(false);
            LOG.error("工作经历审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》不同意（统一接口）
     *
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineTableNo")
    @ResponseBody
    public ResultData examineTableNo(String primitiveId,String businessTypeId, String businessId, String tabName, String dealOpinion, HttpServletRequest request, String createId, String createName) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
//        User user = new User();
//        user.setFax("30132685");
//        user.setUserName("臧家宁");
        try {
            workFlowService.examineTableNo(businessId, tabName, dealOpinion,user.getFax(),user.getName());
            result.setData("审核不通过成功！");
            LOG.info("审核不通过成功！");
          //审核记录入库
            TMouldInfo info = workFlowService.getMouldNameById(businessTypeId);
            TRecordOptLog log = new TRecordOptLog();
            log.setRecordId(primitiveId);
            log.setOptType("8");
            log.setOptTime(new Date());
            log.setOptContent(user.getName() + "审核驳回了" + createName + "提交的" + info.getMouldName() + "，审核意见:" + dealOpinion);
            //保存业务记录操作日志信息记录
            recordLogService.save(user, log);
        } catch (Exception e) {
            result.setErrorMsg("审核不通过异常");
            result.setSuccess(false);
            LOG.error("审核不通过异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，挂职轮岗
     *
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineRotationInfoYes")
    @ResponseBody
    public ResultData examineRotationInfoYes(TRotationInfo rotationInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TRotationInfo oldTRotationInfo = userInfoService.getRotationInfoById(rotationInfo.getId());
            //编辑挂职轮岗信息
            rotationInfo.setFlowStatus(1);//审核通过
            rotationInfo.setIsValid(0);
            workFlowProcessService.updateTRotationInfo(rotationInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(rotationInfo.getId(), user.getFax(), user.getName(), rotationInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("挂职轮岗信息审核成功！");
            LOG.info("挂职轮岗信息审核成功！");
            //审核记录入库
            addRecordLog(rotationInfo.getBusinessTypeId(),rotationInfo.getPrimitiveId(),rotationInfo.getId(),"6",dealOpinion,rotationInfo.getCreaterName(),rotationInfo,oldTRotationInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("挂职轮岗信息审核异常");
            result.setSuccess(false);
            LOG.error("挂职轮岗信息审核异常", e);
        }
        return result;
    }



    /**
     * 审核——》同意，人员流动
     *
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineEmployMobilityYes")
    @ResponseBody
    public ResultData examineEmployMobilityYes(TEmployeeMobility employeeMobility, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        User user = this.getLoginUserInfo(request);
        try {
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
        	TEmployeeMobility oldTEmployeeMobility = userInfoService.getEmployeeMobilityById(employeeMobility.getId());
            //编辑挂职轮岗信息
        	employeeMobility.setFlowStatus(1);//审核通过
        	employeeMobility.setIsValid(0);
            workFlowProcessService.updateTEmployeeMobility(employeeMobility, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(rotationInfo.getId(), user.getFax(), user.getName(), rotationInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("挂职轮岗信息审核成功！");
            LOG.info("挂职轮岗信息审核成功！");
            //审核记录入库
            addRecordLog(employeeMobility.getBusinessTypeId(),employeeMobility.getPrimitiveId(),employeeMobility.getId(),"6",dealOpinion,employeeMobility.getCreaterName(),employeeMobility,oldTEmployeeMobility,user);
        } catch (Exception e) {
            result.setErrorMsg("挂职轮岗信息审核异常");
            result.setSuccess(false);
            LOG.error("挂职轮岗信息审核异常", e);
        }
        return result;
    }


    /**
     * 审核——》同意，技术标准
     *
     * @param tabName
     * @param dealOpinion
     * @return
     */
    @RequestMapping("/examineTecStandardInfoYes")
    @ResponseBody
    public ResultData examineTecStandardInfoYes(TTecStandardInfo tTecStandardInfo, String tabName, String dealOpinion, HttpServletRequest request) {
        ResultData result = new ResultData();
        try {
            User user = this.getLoginUserInfo(request);
            //日志记录--获取未修改之前的业务数据，与修改后的数据进行比较
            TTecStandardInfo oldtTecStandardInfo = userInfoService.getTecStandardInfoById(tTecStandardInfo.getId());
            //编辑技术标准信息
            tTecStandardInfo.setFlowStatus(1);//审核通过
            tTecStandardInfo.setIsValid(0);
            workFlowProcessService.updateTecStandardInfo(tTecStandardInfo, user);//审核时编辑数据
            //流程已改用工作流，不再使用下面方法
//            workFlowService.examineTableYes(rotationInfo.getId(), user.getFax(), user.getName(), rotationInfo.getOrignalId(), dealOpinion, tabName);
            result.setData("技术标准信息审核成功！");
            LOG.info("技术标准信息审核成功！");
            //审核记录入库
            addRecordLog(tTecStandardInfo.getBusinessTypeId(),tTecStandardInfo.getPrimitiveId(),tTecStandardInfo.getId(),"6",dealOpinion,tTecStandardInfo.getCreaterName(),tTecStandardInfo,oldtTecStandardInfo,user);
        } catch (Exception e) {
            result.setErrorMsg("技术标准信息审核异常");
            result.setSuccess(false);
            LOG.error("技术标准信息审核异常", e);
        }
        return result;
    }

    /**
     * 根据业务列别获取，相应的审核人
     *
     * @param businessTypeId
     * @return
     */
    @RequestMapping("/getAuditUserList")
    @ResponseBody
    public ResultData getAuditUserList(String businessTypeId) {
        ResultData result = new ResultData();
        try {

            if (StringUtils.isNotBlank(businessTypeId)) {

            	String users = "{\"success\":true,\"errorMsg\":null,\"data\":\"[{\\\"id\\\":\\\"F2EC41EDCC2F0086E0430A8A018B0086\\\",\\\"provinceid\\\":\\\"暂无\\\",\\\"baseorgId\\\":\\\"F2CDDDB8A4420068E0430A8A018B0068\\\",\\\"relationUserId\\\":\\\"暂无\\\",\\\"name\\\":\\\"臧家宁\\\",\\\"loginName\\\":\\\"zangjn2410\\\",\\\"namecode\\\":\\\"zangjn2410\\\",\\\"state\\\":1,\\\"code\\\":\\\"1511021715\\\",\\\"tel\\\":\\\"暂无\\\",\\\"email\\\":\\\"暂无\\\",\\\"netScope\\\":0,\\\"sysdataid\\\":\\\"暂无\\\",\\\"saphrid\\\":\\\"11021715\\\",\\\"staffPropertiesId\\\":\\\"暂无\\\",\\\"personnelTypeId\\\":\\\"暂无\\\",\\\"title\\\":\\\"暂无\\\",\\\"sexCode\\\":\\\"暂无\\\",\\\"fax\\\":\\\"30132685\\\"},{\\\"id\\\":\\\"FE22F9C1FE7D0024E0430A8A018B0024\\\",\\\"provinceid\\\":\\\"暂无\\\",\\\"baseorgId\\\":\\\"1D2BDED42BC500E2E0530A8A018B00E2\\\",\\\"relationUserId\\\":\\\"暂无\\\",\\\"name\\\":\\\"新门户项目组\\\",\\\"loginName\\\":\\\"xmhxmz\\\",\\\"namecode\\\":\\\"xmhxmz\\\",\\\"state\\\":1,\\\"code\\\":\\\"1580022520\\\",\\\"tel\\\":\\\"13797099132\\\",\\\"email\\\":\\\"xmhxmz@ah.sgcc.com.cn\\\",\\\"netScope\\\":0,\\\"sysdataid\\\":\\\"暂无\\\",\\\"saphrid\\\":\\\"暂无\\\",\\\"staffPropertiesId\\\":\\\"暂无\\\",\\\"personnelTypeId\\\":\\\"暂无\\\",\\\"title\\\":\\\"暂无\\\",\\\"sexCode\\\":\\\"暂无\\\",\\\"fax\\\":\\\"30076901\\\"},{\\\"id\\\":\\\"ff8080815f5d1883015f95a27ca70f17\\\",\\\"provinceid\\\":\\\"暂无\\\",\\\"baseorgId\\\":\\\"1D28EE35916001BCE0530A8A018B01BC\\\",\\\"relationUserId\\\":\\\"暂无\\\",\\\"name\\\":\\\"统一消息平台\\\",\\\"loginName\\\":\\\"tyxxpt\\\",\\\"namecode\\\":\\\"tyxxpt\\\",\\\"state\\\":1,\\\"code\\\":\\\"暂无\\\",\\\"tel\\\":\\\"暂无\\\",\\\"email\\\":\\\"暂无\\\",\\\"netScope\\\":2,\\\"sysdataid\\\":\\\"暂无\\\",\\\"saphrid\\\":\\\"暂无\\\",\\\"staffPropertiesId\\\":\\\"暂无\\\",\\\"personnelTypeId\\\":\\\"暂无\\\",\\\"title\\\":\\\"暂无\\\",\\\"sexCode\\\":\\\"暂无\\\",\\\"fax\\\":\\\"11232071\\\"}]\"}";
                ResultData userList = JSONObject.parseObject(users, ResultData.class);
                List<User> list=JSONObject.parseArray(userList.getData().toString(),User.class);
                userList.setData(list);
                return userList;
          } else {
                result.setErrorMsg("信息类别不能为空");
                result.setSuccess(false);
            }
        } catch (Exception e) {
            result.setErrorMsg("未找到审核人员");
            result.setSuccess(false);
            LOG.error("getAuditUserList：获取审核人员列表错误", e);
        }
        return result;
    }


    /**
     * 审核通过时修改了业务数据，记入日志
     */
    public void addRecordLog(String businessTypeId,String primitiveId,String currentRecordId,String type,String dealOpinion,String createrName,Object newObject,Object oldObject,User user){
        TMouldInfo info = workFlowService.getMouldNameById(businessTypeId);
        TRecordOptLog log = new TRecordOptLog();
        log.setRecordId(primitiveId);
        log.setCurrentRecordId(currentRecordId);
        log.setOptType(type);
        log.setOptTime(new Date());
        if(!StringUtil.isNullOrEmpty(dealOpinion)) {
            Pattern pattern = Pattern.compile("\\pP");
            String content = dealOpinion.substring(dealOpinion.length()-1);
            Matcher matcher = pattern.matcher(content);
            if (matcher.matches()) {
                dealOpinion = dealOpinion.substring(0,dealOpinion.length()-1);
            }
            log.setOptContent(user.getName() + "审核同意了" + createrName + "提交的" + info.getMouldName() + "，审核意见:" + dealOpinion);
        }else {
            log.setOptContent(user.getName() + "审核同意了" + createrName + "提交的" + info.getMouldName());
        }
        //保存业务记录操作日志信息记录
//        recordLogService.save(user, log);
        recordLogService.save(newObject,oldObject,log,user,"1","0");//前面一个参数代表修改/审核，0代表修改，1代表审核；后面一个参数代表是移动端操作/pc端操作，0代表pc端，1代表移动端
    }

}
